package clsr.info.blog.common.config;

import clsr.info.blog.common.pojo.JsonResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@Slf4j
public class ExceptionAdvice {

  @ExceptionHandler(Exception.class)
  @ResponseBody
  public JsonResponse<?> exceptionHandler(Exception e) {
    log.error("controller advice", e);
    return JsonResponse.fail(e.getMessage());
  }
}
